﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Security;
using C3.Proto.Core.Model;
using C3.Proto.Core.Service;
using StructureMap;

namespace C3.Proto.Web.Controllers
{
    [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    public class LoginController : Controller
    {
        public IUserService UserService { get { return ObjectFactory.GetInstance<IUserService>(); } }
        

        public ActionResult Index(string returnUrl)
        {
            return View("Login");
        }



        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult Do(string email, string password)
        {
        
            return Json(UserService.LoginUser(email, password, true));
        }

        public ActionResult Out()
        {
            UserService.LogoutUser();
            return RedirectToAction("Index", "Home");
           
        }



        public ActionResult Reminder()
        {
            return View("Reminder");
        }
        //[AcceptVerbs(HttpVerbs.Post)]
        //public JsonResult SendReminder(string username, string email)
        //{
        //    var t = new TransactionResult() { Successful = false };

        //    if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(email))
        //        return Json(t);

        //    return Json(UserService.SendPasswordReminder(username, email));
        //}


        //public void Sell()
        //{
        //    PropertyService.AddCommission(1,"AA-Listing","50", 2);

        //}
    }
}